// index.js
const util = require('../../../util/util.js')
// const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'

Page({
  data: {
    columns: [{
      key: 'LICENSE_PLATE',
      title: '车辆名称',
      width: 120,
      fixed: 'left',
      align: 'center'
    },
    {
      key: 'CAR_TYPE',
      title: '车辆类型',
      width: 80,
    }, {
      key: 'CLIENT_NAME',
      width: 80,
      title: '所属'
    }
    ],
    dataTable: [],
    carType:''
  },
  
  onLoad: function (options) {
    var that = this;
    that.setData({
      carType:  options.type
    })
    this.getCarRealtimeInfo()
  },
  // 获取信息
  getCarRealtimeInfo() {
    var CLIENT_NO = wx.getStorageSync("CLIENT_NO");
    var that = this;
    const currentDate = new Date();
    currentDate.setDate(currentDate.getDate() - 1);
    wx.request({
      url: 'https://www.ejingyou.cn/ServerHuanwei/CompanyapiBDEapi/Vehicle/GetExcelCar1',
      data: {
        clientNo: CLIENT_NO,
        date: util.formatDateTime(currentDate, true),
        carType:this.data.carType
      },
      header: {
        'content-type': 'application/json' // 默认值     
      },
      success: (res) => {
        // console.log(res.data)
        that.setData({
          dataTable: res.data.slice(1)
        });
      }
    })
  },
  onRowClick () {

  }
  // bindViewTap() {
  //   wx.navigateTo({
  //     url: '../logs/logs'
  //   })
  // },
  // onChooseAvatar(e) {
  //   const { avatarUrl } = e.detail
  //   const { nickName } = this.data.userInfo
  //   this.setData({
  //     "userInfo.avatarUrl": avatarUrl,
  //     hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
  //   })
  // },
  // onInputChange(e) {
  //   const nickName = e.detail.value
  //   const { avatarUrl } = this.data.userInfo
  //   this.setData({
  //     "userInfo.nickName": nickName,
  //     hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
  //   })
  // },
  // getUserProfile(e) {
  //   // 推荐使用wx.getUserProfile获取用户信息，开发者每次通过该接口获取用户个人信息均需用户确认，开发者妥善保管用户快速填写的头像昵称，避免重复弹窗
  //   wx.getUserProfile({
  //     desc: '展示用户信息', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
  //     success: (res) => {
  //       console.log(res)
  //       this.setData({
  //         userInfo: res.userInfo,
  //         hasUserInfo: true
  //       })
  //     }
  //   })
  // },
})
